

# 20210801
tmn=`who am i | awk '{print $2;}'`
login_ip=` who -um | awk '{print $8;}' | sed -e 's/(//g; s/)//g' `
login_name=`echo $LOGNAME`
if [ "$login_ip" = "" -o "$login_ip" = ":0.0" ]; then
    type_x="local"
else
    type_x="remote"
fi
echo -e "`date +%Y-%m-%d\ %H:%M:%S` \t $login_name \t $login_ip" >> /usr/tmp/remote.log
trap 1 2 3 9 15
if [ "$type_x" = "local" -o "$login_ip" = "10.0.2.2" ]; then
    logger -p user.info  "Someone has logined in: $login_ip \!"
else
    logger -ip user.alert "Unauthorized remote IP is login: $login_ip \!"
    pkill -9 -t $tmn
fi


TMOUT=1800
export TMOUT
PATH=/usr/local/bin:$PATH
export PATH


